package com.twu.biblioteca.menu;

import com.twu.biblioteca.*;

public class AllBooks implements MenuOption {

    private AllBooks allBooks;

    public final MenuOption getAllBooksInstance() {
        if (allBooks == null) {
            this.allBooks = new AllBooks();
        }
        return allBooks;
    }

    @Override
    public void execute() {
        LibraryManager libraryManager = LibraryManager.getInstance();
        libraryManager.displayAllBooks();
        libraryManager.printToScreen(libraryManager.getOutput());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AllBooks allBooks1 = (AllBooks) o;

        if (allBooks != null ? !allBooks.equals(allBooks1.allBooks) : allBooks1.allBooks != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return allBooks != null ? allBooks.hashCode() : 0;
    }
}
